<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<style>

</style>
<form:form commandName="logs" cssClass="form-horizontal" role="form" onsubmit="return false;">
    <c:if test="${empty logs}">
        <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right" style="color: #761c19">无攻坚反馈日志！</label>
        </div>
    </c:if>
    <c:forEach items="${logs}" var="logs">
        <c:if test="${not empty logs}">
            <%--督查记录--%>
            <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right">反馈时间</label>
                <div class="col-sm-3">
                    <input type="text" value="${logs.createDate} ${logs.createTime}" readonly="readonly"
                           class="form-control ">
                </div>
                <label class="col-sm-1 control-label no-padding-right">反馈人员</label>
                <div class="col-sm-3">
                    <input type="text" title="${logs.recordPerson}" value="${logs.recordPerson}" readonly="readonly"
                           placeholder="反馈人员" class="form-control">
                </div>
                <div class="col-sm-2">
                    <button type="button" class="btn btn-sm btn-primary downloadFile" data-id="${logs.taxproof}"
                            style="width: 100%;">下载附件
                    </button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right supLog">反馈记录</label>
                <div class="col-sm-11">
                    <textarea rows="3" class="form-control" readonly="readonly">${logs.record}</textarea>
                </div>
            </div>
        </c:if>
    </c:forEach>
    <hr width="100%;height:2px;" style="border-top: 1px solid #aaa; margin: 0;">
    <div class="form-group" id="finishTack_div" style="display: none">
        <div class="col-sm-2 pull-right">
            <button class="btn btn-large btn-warning" id="finishTack_btn">任务办结</button>
        </div>
    </div>
    <div class="form-group" id="approvalTack_div" style="display: none">
        <label class="col-sm-8 control-label no-padding-right">办结时间</label>
        <div class="col-sm-2 pull-left">
            <input type="text" class="form-control" readonly placeholder="无" value="${finishTackDate}"/>
        </div>
        <div class="col-sm-2 pull-right">
            <button class="btn btn-large btn-danger" id="approvalTack_btn">任务审核</button>
        </div>
    </div>
    <div class="form-group" id="approvaledTack_div" style="display: none">
        <label class="col-sm-5 control-label no-padding-right" style="color: red">攻坚任务已完成！</label>
        <div class="col-sm-7 pull-left">
            <input type="text" class="form-control" readonly
                   value="计划完成时间：${task.planEndDate}，办结时间：${task.finishTackDate}，及时完成率：${task.tackPercent}%"/>
        </div>
    </div>
    <%--任务id  隐藏--%>
    <input type="text" id="taskId" value="${task.sysId}" style="display:none;">
</form:form>
<script type="text/javascript">
    var taskId = $("#taskId").val();
    var auth = ${bnpUser.branchType}
    var tackFlag = ${task.tackFlag};
    if (tackFlag == "1") {
        $("#finishTack_div").css("display", "inline");
    } else if (tackFlag == '2') {
        if(auth == '2'){
            $("#approvalTack_div").css("display", "inline");
        }
    } else if (tackFlag == '3') {
        $("#approvaledTack_div").css("display", "inline");
    }
    /**
     * 下载
     */
    $(".downloadFile").click(function () {
        var id = $(this).data("id");
        var url = "/communal/download/" + id;
        window.open(url);
    });
    jQuery(function ($) {
        $('.date-picker').datepicker({
            inline: true,
            format: "yyyymmdd",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        })
        //show datepicker when clicking on the icon
            .next().on(ace.click_event, function () {
            $(this).prev().focus();
        });
        $(".downloadFile").each(function () {
            if (isEmpty($(this).data("id"))) {
                $(this).attr("style", "display:none;");
            }
        });
    });

    //************************************任务办结（可进行反馈也可进行办结）************************************
    $("#finishTack_btn").click(function () {
        var taskId = $("#taskId").val();
        loadDialog({
            dialogTitle: '任务办结',
            dialogUrl: baseUrl + "addTackLog/" + taskId,
            dialogFoot: '<button type="button" class="btn btn-info" data-dismiss="modal" onclick="tackLog_back()">返回</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>'
        });
    });

    //************************************任务审核（可进行反馈也可进行办结）************************************
    $("#approvalTack_btn").click(function () {
        var taskId = $("#taskId").val();
        loadDialog({
            dialogTitle: '任务审核',
            dialogUrl: baseUrl + "approval/" + taskId,
            dialogFoot: '<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="tackLog_back()">撤销审核</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>'
        });
    });

</script>